/**
 * Created by liuqingling on 16/1/27.
 */

define(['backbone'], function(Backbone) {
    var items = [{
        'id':1,
        'label': '领域',
        'content':'财务会计',
        'mode':1,//0为多选,1为单选
        'data':[{
            id: '0',
            isselect:true,
            title:'财务会计'
        }]

    },{
        'id':2,
        'label': '版本',
        'content':'全部',
        'mode':0,//0为多选,1为单选
        'data':[{
            id: '1',
            isselect:true,
            title:'6.5',
        }]
    },{
        'id':3,
        'label': '主题类型',
        'content':'全部',
        'mode':0,//0为多选,1为单选
        'data':[{
            id: '1',
            isselect:true,
            title:'功能特性',
        },{
            id: '2',
            isselect:true,
            title:'应用方案',
        },{
            id: '3',
            isselect:true,
            title:'最佳实践',
        },{
            id: '4',
            isselect:true,
            title:'竞争分析',
        },{
            id: '5',
            isselect:true,
            title:'培训课件',
        },{
            id: '6',
            isselect:true,
            title:'移动app',
        },{
            id: '7',
            isselect:true,
            title:'微信应用',
        }]
    },{
        'id':4,
        'label': '状态',
        'content':'全部',
        'mode':0,//0为多选,1为单选
        'data':[{
            id: '1',
            isselect:true,
            title:'正式版',
        },{
            id: '2',
            isselect:true,
            title:'孵化版',
        },{
            id: '3',
            isselect:true,
            title:'在研',
        },{
            id: '4',
            isselect:true,
            title:'预研',
        }]
    }];

    var Model = Backbone.Model.extend({});

    var collections = Backbone.Collection.extend({
        model: Model,
        url: "./api/showcase",
        state: {},
        fetch: function() {
            this.addItem();
        },

        addItem: function(){
            for (var i = 0; i < this.pageSize; i++) {
                var position = this.curPageIndex * this.pageSize + i;
                if(items.length > position){
                    this.add(new Model(items[position]));
                }else{
                    break;
                }
            }
        },

        curPageIndex: 0,
        pageSize: 10,
        getNextPage: function() {
            this.curPageIndex += 1;
            this.addItem();
        },
        hasNextPage: function() {
            return items.length/ this.pageSize > this.curPageIndex;
        },
        getFirstPage: function() {
            this.curPageIndex = 0;
            this.addItem();
        },
    });

    return collections;
});
